package com.cmy.array;

import java.util.Arrays;

public class Arr {
    public static void main(String[] args) {
        int[] numbers = {1,2,3,4,5,6,7};//定义+初始化
        //遍历数组
        for(int x:numbers) {
            System.out.println(x);
        }

        printArray(numbers);


        for (int x:aReverseOrdr(numbers)){
            System.out.println(x);
        }

        int[] a = {1,2,3,4,12,6,8,7,5};
        //打印数组
        System.out.println(Arrays.toString(a));
        //排序
        Arrays.sort(a);
        System.out.println(Arrays.toString(a));


    }

    public static void test(){
        int[] numbers1 = new int[10];
        for(int x:numbers1){
            System.out.println(x);
        }
    }

    //数组作为参数
    public static void printArray(int[] arrays){
        for(int x:arrays){
            System.out.println(x);
        }
    }
    //数组作为返回值,逆序输出数组
    public static int[] aReverseOrdr(int[] arrays){
        int temp = 0;
        int head = 0;
        int tail = arrays.length-1;
        while(head<tail){
            temp = arrays[head];
            arrays[head] = arrays[tail];
            arrays[tail] = temp;
            head++;
            tail--;
        }
        return arrays;
    }


}

    